const state = {
  cartData: []
}

const mutations = {
  addCart(state, data) {
    let isHasCourt = state.cartData.find(o => o.id === data.id);
    if (isHasCourt) {
      isHasCourt.num += 1
    } else [
      state.cartData.push({
        ...data,
        num: 1
      })
    ]
  },
  minus(state) {

  }
}
const getters = {
  allCartGoodsNum(state) {
    let num = 0;
    state.cartData.forEach(item => {
      num += item.num
    })
    return num
  }
}
//异步都用actions
const actions = {
 
}

export default {
  state,
  mutations,
  getters,
  actions
}
